package com.day21me.java;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Test1 {
    public static void main(String[] args) {
        try {
            ServerSocket ss = new ServerSocket(8899);
            Socket socket = ss.accept();

            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String s =br.readLine();
            System.out.println("你好，客户端，这里是服务器，我收到了你的信息："+s);

            socket.shutdownInput();
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            bw.write("你好，客户sb，收到你的消息");
            bw.flush();
            bw.close();

            socket.close();


        }catch (Exception ex){
            ex.printStackTrace();
        }

    }


}
